﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;
//using MySql.Data;
using MySql.Data.MySqlClient;

namespace BankOrder
{
    class StaffSql
    {
        private string url = "server=127.0.0.1;port=3306;user=root;password=123456;database=bank;Charset=utf8;SslMode=None;";
        private string sql = "";
        private MySqlDataReader reader = null;
        public bool loginServe(string id,string pwd)
        {
            bool flag = false;
            sql = string.Format("select * from staffinfo where sid='{0}' and spwd='{1}';", id, pwd);
            Debug.console(sql);
            MySqlConnection mySqlConnection = new MySqlConnection(url);
            try
            {
                mySqlConnection.Open();
                MySqlCommand mySqlCommand = new MySqlCommand(sql, mySqlConnection);
                reader = mySqlCommand.ExecuteReader();
                if (reader.Read())
                {
                    //Debug.messageBox("登录成功");
                    flag = true;

                }
                else
                {
                    //Debug.messageBox("登陆失败");
                }
                mySqlConnection.Close();
            }
            catch
            {
                mySqlConnection.Close();
            }
            finally
            {
                mySqlConnection.Close();
            }
            return flag;
        }
    }
}
